using System.Threading.Tasks;
using System.Xml.Serialization;
using Buddy.Coroutines;
using log4net;
using Triton.Common.LogUtilities;

namespace Triton.Bot.Profiles
{
	[XmlRoot("Function")]
	[ProfileElementName("Function")]
	public class FunctionTag : ProfileGroupElement
	{
		private readonly ILog ilog_0 = Logger.GetLoggerInstanceForType();

		private bool bool_0;

		public override string Name => "Function";

		public override string Author => "Bossland GmbH";

		public override string Description => "";

		public override string Version => "1.0.0.0";

		public override bool IsFinished => bool_0;

		public override async Task ProfileTagLogic()
		{
			if (ReferenceName == null && ReferenceTag == null)
			{
				ilog_0.Info("Cannot execute a Function tag that has no reference name, or tag set. This tag is only meant for easily referencing profile behavior steps in sequence.");
				BotManager.Stop();
				await Coroutine.Yield();
				return;
			}
			foreach (ProfileElement child in Children)
			{
				child.Reset();
				await child.ProfileTagLogic();
			}
			bool_0 = true;
		}

		public override void Reset()
		{
			bool_0 = false;
			base.Reset();
		}
	}
}
